//
//  WJTabBarViewController.m
//  咸鱼翻身
//
//  Created by wenjian on 16/4/23.
//  Copyright © 2016年 xmg. All rights reserved.
//

#import "WJTabBarViewController.h"
#import "WJMainPageTableViewController.h"
#import "WJNewsTableViewController.h"
#import "WJTaskTableViewController.h"
#import "WJPersonnelTableViewController.h"
#import "WJNavigationController.h"


@interface WJTabBarViewController ()

@end

@implementation WJTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //1.添加所有子控制器
    WJMainPageTableViewController *MainPageVC = [[WJMainPageTableViewController alloc]init];
    [self addOneChildVC:MainPageVC title:@"首页" image:[UIImage imageNamed:@"tabBar_essence_icon"] selImage:[UIImage imageNamed:@"tabBar_essence_click_icon"]];
    
    WJTaskTableViewController *TaskVC = [[WJTaskTableViewController alloc]init];
    [self addOneChildVC:TaskVC title:@"任务" image:[UIImage imageNamed:@"tabBar_new_icon"] selImage:[UIImage imageNamed:@"tabBar_new_click_icon"]];
    
    UIViewController *VC = [[UIViewController alloc]init];
    [self addOneChildVC:VC title:nil image:nil selImage:nil];
    
    
    WJNewsTableViewController *NewsVC = [[WJNewsTableViewController alloc]init];
    [self addOneChildVC:NewsVC title:@"消息" image:[UIImage imageNamed:@"tabBar_friendTrends_icon"] selImage:[UIImage imageNamed:@"tabBar_friendTrends_click_icon"]];

    
    WJPersonnelTableViewController *PersonnelVC = [[WJPersonnelTableViewController alloc]init];
    [self addOneChildVC:PersonnelVC title:@"个人中心" image:[UIImage imageNamed:@"tabBar_friendTrends_icon"] selImage:[UIImage imageNamed:@"tabBar_friendTrends_click_icon"]];
    
    
}

-(void)addOneChildVC:(UIViewController *)VC title:(NSString *)title image:(UIImage *)image selImage:(UIImage *)selImage
{
    WJNavigationController *nav = [[WJNavigationController alloc]initWithRootViewController:VC];
    VC.navigationItem.title = title;
        
    nav.tabBarItem.title = title;
    nav.tabBarItem.image = image;
    nav.tabBarItem.selectedImage = selImage;
    [self addChildViewController:nav];

}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    //创建一个按钮
    UIButton *PubBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    //设置图片
    [PubBtn setImage:[UIImage imageNamed:@"tabBar_publish_icon"] forState:UIControlStateNormal];
    [PubBtn setImage:[UIImage imageNamed:@"tabBar_publish_click_icon"] forState:UIControlStateSelected];
    //设置btn的位置
    
    PubBtn.frame = CGRectMake(0, 0, self.tabBar.bounds.size.width / 5, self.tabBar.bounds.size.height * 1.5);
    PubBtn.center = CGPointMake(self.tabBar.bounds.size.width * 0.5, self.tabBar.bounds.size.height * 0.5);
    
    [self.tabBar addSubview:PubBtn];
    NSLog(@"%@",self.tabBar.superclass);

}



@end
